import 'package:flutter/material.dart';
import 'package:wechat/pages/discover/discover_cell.dart';

class DiscoverPage extends StatefulWidget {
  const DiscoverPage({Key? key}) : super(key: key);

  @override
  State<DiscoverPage> createState() => _DiscoverPageState();
}

class _DiscoverPageState extends State<DiscoverPage> with AutomaticKeepAliveClientMixin<DiscoverPage>{
  Color _themeColor = Color.fromRGBO(223, 223, 223, 1);

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return Scaffold(
      appBar: AppBar(
        title: Text(
          "发现",
          style: TextStyle(color: Colors.black),
        ),
        centerTitle: true,
        backgroundColor: _themeColor,
        elevation: 0.0,
      ),
      body: Container(
          color: _themeColor,
          child: DiscoverList(),
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;

  @override
  void dispose() {
    super.dispose();
    print("发现界面销毁了");
  }
}

class DiscoverList extends StatelessWidget {
  const DiscoverList({Key? key}) : super(key: key);


  @override
  Widget build(BuildContext context) {
    return ListView(
      children: [
        DiscoverCell(
          imageName: "images/discover/朋友圈.png",
          title: "朋友圈",
        ),
        SizedBox(height: 15),
        DiscoverCell(
          imageName: "images/discover/朋友圈.png",
          title: "视频号",
        ),
        SizedBox(height: 15),
        DiscoverCell(
          imageName: "images/discover/扫一扫.png",
          title: "扫一扫",
        ),
        Stack(
          children: [
            Container(
              height: 0.5,
              color: Colors.grey,
            ),
            Container(
              color: Colors.white,
              width: 35,
              height: 0.5,
            )
          ],
        ),
        DiscoverCell(
          imageName: "images/discover/摇一摇.png",
          title: "摇一摇",
        ),
        SizedBox(height: 15),
        DiscoverCell(
          imageName: "images/discover/看一看.png",
          title: "看一看",
        ),
        Stack(
          children: [
            Container(
              height: 0.5,
              color: Colors.grey,
            ),
            Container(
              color: Colors.white,
              width: 35,
              height: 0.5,
            )
          ],
        ),
        DiscoverCell(
          imageName: "images/discover/搜一搜.png",
          title: "搜一搜",
        ),
        SizedBox(height: 15),
        DiscoverCell(
          imageName: "images/discover/朋友圈.png",
          title: "直播和附近",
        ),
        SizedBox(height: 15),
        DiscoverCell(
          imageName: "images/discover/购物.png",
          title: "购物",
          subTitle: "11.11京东官方补贴",
          subImageName: "images/discover/badge.png",
        ),
        Stack(
          children: [
            Container(
              height: 0.5,
              color: Colors.grey,
            ),
            Container(
              color: Colors.white,
              width: 35,
              height: 0.5,
            )
          ],
        ),
        DiscoverCell(
          imageName: "images/discover/游戏.png",
          title: "游戏",
        ),
        SizedBox(height: 15),
        DiscoverCell(
          imageName: "images/discover/小程序.png",
          title: "小程序",
        ),
      ],
    );
  }
}

